package com.scs.application.modules.wm.controller;

import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.core.query.QueryContext;
import com.scs.application.core.query.QueryContextHolder;
import com.scs.application.modules.sys.model.PageResult;
import com.scs.application.modules.sys.model.RestResult;
import com.scs.application.modules.wm.dto.WorkOrderItemDTO;
import com.scs.application.modules.wm.entity.WorkOrderItem;
import com.scs.application.modules.wm.service.WorkOrderItemService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 入库单明细 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/wm/work_order_item")
public class WorkOrderItemController extends CrudController<WorkOrderItemService, WorkOrderItem> {


    /**
     *  冲红选择耗材列表
     * @return
     */
    @GetMapping("/pageForRedType")
    public PageResult pageForRedType() {
        QueryContext queryContext = QueryContextHolder.currentContext();
        return service.pageForRedType(queryContext);
    }

    /**
     * 跟台包查询
     * @return
     */
    @GetMapping("/selectOprtBag")
    public RestResult selectOprtBag(){
        return RestResult.ok("查询成功",service.selectOprtBag());
    }

    /**
     * 根据耗材ID 查询 work_order_item
     *
     * @param matrId
     * @return
     */
    @GetMapping("/getListByMatrId")
    public RestResult getListByMatrId(@RequestParam("matrId") String matrId) {
        List<WorkOrderItemDTO> workOrderItemDTOS = service.getListByMatrId(matrId);
        return RestResult.ok("success", workOrderItemDTOS);
    }
}
